package com.chhh.cranelease.controller.baseinfocontroller;

import com.chhh.cranelease.entity.CraneBrand;
import com.chhh.cranelease.model.ResponseCode;
import com.chhh.cranelease.service.BaseInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;

@RestController
@RequestMapping("car/")
public class CompanyController {

    @Autowired
    private BaseInfoService baseInfoService;

    private ResponseCode responseCode = new ResponseCode();

    @RequestMapping("selectStyle")
    public String selectStyle(String model_id){
        String path = baseInfoService.selectStyle(model_id);
        return path;
    }
    @RequestMapping("insertStyle")
    public ResponseCode insertStyle(@RequestParam(value = "files",required = false)MultipartFile files, Integer model_id, String  description)  {

        Integer style = null;
        try {
            style = baseInfoService.insertStyle(files,model_id,description);
        } catch (Exception e) {
            e.printStackTrace();
        }
        responseCode.setErrorCode(0);
        responseCode.setStatus("你更新了"+style+"张图片");
        return responseCode;
    }

}
